import java.io.IOException;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.Arrays;
import java.nio.file.Files;
import java.nio.charset.Charset;
import java.util.HashMap;
import java.util.List;


public class Output {
   
    String[] s30=new String[3];
    List<String> lines;
    public void output20(String filePath20,Itemsets closedItemsets,HashMap<Integer, String> num2Attr,String[] attrNames,int n2) {                
    	     
    	     Path out10=Paths.get(filePath20);
            
                  Charset charset=Charset.forName("UTF-8");
                  int l=closedItemsets.getLevels().size()-1;
                  //System.out.println("l="+l);
                  for (int k=l; k>0; k--){
                     for (Itemset i: closedItemsets.getLevels().get(k)){
                    	// System.out.println(i.toString()); 
                    	String line="";
                    	String line2="";
                    	int x;
                    	String[] arrayline=new String[n2];
                    	for(int j=1;j<=n2;j++) {
                    		arrayline[j-1]="?,";
                    	}
                    	for( x=1; x<=n2; x++) {
                    		start:
                    		 for(int p:i.itemset){
                                 String str30=num2Attr.get(p);
                                 s30=str30.split(":");
                                 if(attrNames[x-1].equals(s30[0])){
                                	 arrayline[x-1]=s30[1]+",";
                                     break start;                         	
                                 }
                    		 }
                                        		 
                          }
                    	for( x=1; x<=n2; x++) {
                    		line=line+arrayline[x-1];
                    	}
                    	line=line+s30[2];
                    	int l20=line.length();
                    	
                        lines=Arrays.asList(line,line2);
                        try {
                        	if(i.itemset.size()==l) {
                        		System.out.println(l+"项集频次："+i.cardinality+";");
                        		for( x=1;x<=i.cardinality;x++) {
                                    Files.write(out10,lines,charset,StandardOpenOption.CREATE,StandardOpenOption.APPEND); 
                             	}
                        	}
                        }catch(IOException ex) {
            	            ex.printStackTrace();
                        }
                      }  
                    }
           }    
             
}